package bairui.international.console.web.controller.personnel.position;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianjing.sh.project.authority.model.status.State_Role;
import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.output.FomatOutput;
import com.sh_lianjing.util.Util_BeanCopyByDeclaredProperties;

import bairui.international.model.domain.jpa.TB_Position;
import bairui.international.service.Service_Position;


/**
 * @generated
 *
 * C_Personnel_Position_Add
 *
 */
@Controller
public class C_Personnel_Position_Add
 extends SC_Personnel_Position_Add 
{
	
	@Autowired @Lazy private Service_Position service_Position;
	
	/**
	 * 添加
	 */
	@Action(Add.class)
	@PostMapping(Add.RequestMappingValue)
	public @FomatOutput @ResponseBody Object add(
		@Valid Add.InputModel input, 
		@PathVariable(name=Add.PathVariableName.ParentId) Long parentId
	) throws Exception {
		TB_Position bean = Util_BeanCopyByDeclaredProperties.copyProperties(input, new TB_Position());
		if(null != parentId){
			bean.setParent(new TB_Position(parentId));
		}
		bean.setRoleState(State_Role.Activated);
		service_Position.save(bean);
		//
		return null;
	}
	

}


